package organizer;

/**
 * Default mutable implementation the file metadata.
 * @author dawong
 */
public class FileMetadata implements IFileMetadata {
    
    private String path;
    private String contentHash;
    private long length;
    private long modifiedDate;

    public FileMetadata() {
    }

    public FileMetadata(IFileMetadata orig) {
        this(orig.getPath(), orig.getLength(), orig.getModifiedDate(), orig.getContentHash());
    }

    public FileMetadata(String path, long length, long modifiedDate) {
        this.path = path;
        this.length = length;
        this.modifiedDate = modifiedDate;
    }

    public FileMetadata(String path, long length, long modifiedDate, String contentHash) {
        this(path, length, modifiedDate);
        this.contentHash = contentHash;
    }

    @Override
    public String getContentHash() {
        return contentHash;
    }

    public void setContentHash(String contentHash) {
        this.contentHash = contentHash;
    }

    @Override
    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public long getLength() {
        return length;
    }

    public void setLength(long length) {
        this.length = length;
    }

    public long getModifiedDate() {
        return modifiedDate;
    }

    public void setModifiedDate(long modifiedDate) {
        this.modifiedDate = modifiedDate;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 79 * hash + (this.path != null ? this.path.hashCode() : 0);
        hash = 79 * hash + (this.contentHash != null ? this.contentHash.hashCode() : 0);
        hash = 79 * hash + (int) (this.length ^ (this.length >>> 32));
        hash = 79 * hash + (int) (this.modifiedDate ^ (this.modifiedDate >>> 32));
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final FileMetadata other = (FileMetadata) obj;
        if ((this.path == null) ? (other.path != null) : !this.path.equals(other.path)) {
            return false;
        }
        if ((this.contentHash == null) ? (other.contentHash != null) : !this.contentHash.equals(other.contentHash)) {
            return false;
        }
        if (this.length != other.length) {
            return false;
        }
        if (this.modifiedDate != other.modifiedDate) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "FileMetadata{" + "path=" + path + ", contentHash=" + contentHash + ", length=" + length + ", modifiedDate=" + modifiedDate + '}';
    }

}
